
<template>
  <!--  :span-method="objectSpanMethod" -->
  <el-table align="center" :data="goodsDataList" border>
    <el-table-column
      :key="Math.random()"
      align="center"
      label="识别码"
      prop="goodsFullCode"
      width="150px"
    />
    <el-table-column
      :key="Math.random()"
      align="center"
      label="货号"
      prop="goodsCode"
      width="150"
    />
    <el-table-column
      :key="Math.random()"
      align="center"
      label="货品简称"
      prop="goodsAbbr"
      width="150px"
    />
    <el-table-column
      :key="Math.random()"
      align="center"
      label="批号"
      prop="goodsBatchCode"
      width="120px"
    />

    <el-table-column
      :key="Math.random()"
      align="center"
      label="浓度"
      width="80px"
    >
      <template slot-scope="{ row }">
        {{ row.concentration }} {{ row.concentrationUnit }}
      </template>
    </el-table-column>
    <!-- <el-table-column
    align="center"
      v-if="goodsType === 1"
      :key="Math.random()"
      label="状态"
      width="100px"
    >
      <template slot-scope="{ row }">
        <el-tag v-if="row.type === 2">分装前</el-tag>
        <el-tag v-else type="success">分装后</el-tag>
      </template>
    </el-table-column> -->
    <el-table-column
      :key="Math.random()"
      align="center"
      label="规格"
      prop="expirationDate"
      width="100px"
    >
      <template slot-scope="{ row }">
        <span v-if="row.specification">
          {{ row.specification }} {{ row.unit }}
        </span>
      </template>
    </el-table-column>
    <el-table-column
      v-if="openType === 'order'"
      :key="Math.random()"
      align="center"
      label="个数"
      prop="expectCount"
      width="80px"
    />
    <el-table-column
      v-if="openType === 'order'"
      :key="Math.random()"
      align="center"
      label="数量"
      prop="expectQuantity"
      width="100px"
    >
      <template slot-scope="{ row }">
        <span v-if="row.expectQuantity">
          {{ row.expectQuantity }} {{ row.unit }}
        </span>
      </template>
    </el-table-column>
    <el-table-column
      v-if="openType === 'result'"
      :key="Math.random()"
      align="center"
      label="个数"
      prop="factCount"
      width="100px"
    />
    <el-table-column
      v-if="openType === 'result'"
      :key="Math.random()"
      align="center"
      label="数量"
      prop="factQuantity"
      width="100px"
    >
      <template slot-scope="{ row }">
        <span v-if="row.factQuantity">
          {{ row.factQuantity }} {{ row.unit }}
        </span>
      </template>
    </el-table-column>
    <el-table-column
      align="center"
      label="生产日期"
      width="120px"
      prop="productionDate"
    />
    <el-table-column
      align="center"
      label="失效日期"
      width="120px"
      prop="expirationDate"
    />
  </el-table>
</template>

<script>
export default {
  props: {
    goodsDataList: {
      required: true,
      type: Array,
      default: function() {
        return []
      }
    },
    goodsType: {
      type: Number,
      default: 1
    },
    openType: {
      type: String,
      default: null
    }
  },
  data() {
    return {
      tableData: []
    }
  },
  watch: {},
  mounted() {},
  methods: {
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex <= 2) {
        if (row.rowspan !== 1) {
          return {
            rowspan: row.rowspan,
            colspan: 1
          }
        } else {
          return {
            rowspan: 0,
            colspan: 0
          }
        }
      }
    },
    A(data, code) {
      // 处理数据
      for (let i = data.length - 1; i > 0; i--) {
        if (!data[i].rowspan) {
          data[i].rowspan = 1
        }
        if (data[i].goodsCode === data[i - 1].goodsCode) {
          data[i - 1].rowspan = data[i].rowspan + 1
          data[i].rowspan = 1
        }
      }
    }
  }
}
</script>

<style>
</style>

